<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <meta charset="utf-8">
    <title>微信支付</title>
    <link type="text/css" rel="stylesheet" href="${ctxStatic}/merchant/css/index.css"/>
    <link type="text/css" rel="stylesheet" href="${ctxStatic}/merchant/css/layui.css"/>
    <link type="text/css" rel="stylesheet" href="${ctxStatic}/merchant/css/pay/charge.css"/>
    <link type="text/css" rel="stylesheet" href="${ctxStatic}/merchant/css/pay/weixincode.css"/>
    <script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
    <script src="${ctxStatic}/merchant/js/jquery-3.3.1.min.js" type="text/javascript"></script>
    <script src="${ctxStatic}/merchant/js/layui.all.js" type="text/javascript"></script>
    <script type="text/javascript">

        // var qrcode;

        $(document).ready(function () {
            /*$.ajax({
                url: "
            \\${ctx}/shop/shop/hkShopCoupon/getWxCodeUrl",
                type: "GET",
                data: {
                    "money":
            \\${requestScope.money}
                },
                success: function (res) {
                    if (res != null) {
                        qrcode = new QRCode(document.getElementById("qrcode"), {
                            text: "购买乐币",
                            width: 200,
                            height: 200,
                            colorDark: "#000000",
                            colorLight: "#ffffff",
                            correctLevel: QRCode.CorrectLevel.H
                        });
                        qrcode.clear();
                        qrcode.makeCode(res.codeUrl);
                    }
                }, error: function () {
                    $.jBox.alert("网络异常,请稍后重试！", error);
                }
            });*/

            var qrcode = new QRCode(document.getElementById("qrcode"), {
                text: "购买乐币",
                width: 200,
                height: 200,
                colorDark: "#000000",
                colorLight: "#ffffff",
                correctLevel: QRCode.CorrectLevel.H
            });
            qrcode.clear();
            qrcode.makeCode(${requestScope.codeUrl});


            function valiPayResult() {
                // qrcode.clear();
                $.ajax({
                    url: "${ctx}/shop/shop/hkShopCoupon/voliPayResult",
                    type: "GET",
                    data: {
                        "integral": ${requestScope.integral},
                        "orderNumber": ${requestScope.orderNumber}
                    },
                    success: function (res) {
                        if (res != null && res == "success") {
                            $("#wxzf").css('display', 'none');
                            $.jBox.alert("充值成功,请保存优惠券！");
                            loading('正在提交，请稍等...');
                            form.submit();
                        } else
                            $.jBox.alert("充值结果获取失败，请稍后重试！");
                    }, error: function () {
                        $.jBox.alert("网络异常,请稍后重试！", error);
                    }
                });
            }

            function wxzf() {
                $("#wxzf").css('display', 'block');
            }

            $("#back").click(function () {
                alert(111)
                window.location.href = "${fns:getAdminPath()}/shop/shop/hkShopCoupon/goWXPay";
            })

        });

    </script>
</head>
<body>
<header></header>
<div class="content">
    <ul class="nav nav-tabs">
        <%--<li><a href="${ctx}/shop/shop/hkShopCoupon/goWXPay">充值</a></li>--%>
        <li class="active"><a href="${ctx}/shop/shop/hkShopCoupon/goWXPayCode">支付</a>
        </li>
    </ul>
    <br/>
    <div class="content-table">
        <div class="table-title">
            <span>微信支付</span>
            <span>应支付金额：<i>${requestScope.money}</i><i>元</i></span>
        </div>
        <div class="code clearfix">
            <div style="float: left;margin-top:20px;">
                <%--<img id="code" src="${ctxStatic}/merchant/images/pay/1415056808771.png"/>--%>
                <div id="code">
                    <div id="qrcode"></div>
                </div>
                <span class="codeMess">
							<i>请使用微信扫一扫</i>
							<i>扫描二维码支付</i>
						</span>
            </div>
            <img id="mobile" src="${ctxStatic}/merchant/images/pay/syswx.png"/>
        </div>

        <div class="payment">
            <input type="button" id="back" style="background-color: #E8E7E3" value="返  回"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" id="valiPayResult" value="获取支付结果"/>
        </div>

    </div>
    <%--<input type="button" id="close" class="btn" value="关闭" style="margin-left:76px;" onClick="wxzf()">
    <input type="button" onclick="valiPayResult()" class="btn btn-primary" value="获取支付结果">--%>
</div>
</body>
</html>